package com.ruoyi.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SuperPickupPoint;
import com.ruoyi.system.service.ISuperPickupPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 自提点:自提点信息,字段包括id,名称,地址电话Controller
 * 
 * @author ruoyi
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/tool/pointpick")
public class SuperPickupPointController extends BaseController
{
    @Autowired
    private ISuperPickupPointService superPickupPointService;

    /**
     * 查询自提点:自提点信息,字段包括id,名称,地址电话列表
     */
    @PreAuthorize("@ss.hasPermi('tool:pointpick:list')")
    @GetMapping("/list")
    public TableDataInfo list(SuperPickupPoint superPickupPoint)
    {
        startPage();
        List<SuperPickupPoint> list = superPickupPointService.selectSuperPickupPointList(superPickupPoint);
        return getDataTable(list);
    }

    /**
     * 导出自提点:自提点信息,字段包括id,名称,地址电话列表
     */
    @PreAuthorize("@ss.hasPermi('tool:pointpick:export')")
    @Log(title = "自提点:自提点信息,字段包括id,名称,地址电话", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SuperPickupPoint superPickupPoint)
    {
        List<SuperPickupPoint> list = superPickupPointService.selectSuperPickupPointList(superPickupPoint);
        ExcelUtil<SuperPickupPoint> util = new ExcelUtil<SuperPickupPoint>(SuperPickupPoint.class);
        util.exportExcel(response, list, "自提点:自提点信息,字段包括id,名称,地址电话数据");
    }

    /**
     * 获取自提点:自提点信息,字段包括id,名称,地址电话详细信息
     */
    @PreAuthorize("@ss.hasPermi('tool:pointpick:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(superPickupPointService.selectSuperPickupPointById(id));
    }

    /**
     * 新增自提点:自提点信息,字段包括id,名称,地址电话
     */
    @PreAuthorize("@ss.hasPermi('tool:pointpick:add')")
    @Log(title = "自提点:自提点信息,字段包括id,名称,地址电话", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SuperPickupPoint superPickupPoint)
    {
        return toAjax(superPickupPointService.insertSuperPickupPoint(superPickupPoint));
    }

    /**
     * 修改自提点:自提点信息,字段包括id,名称,地址电话
     */
    @PreAuthorize("@ss.hasPermi('tool:pointpick:edit')")
    @Log(title = "自提点:自提点信息,字段包括id,名称,地址电话", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SuperPickupPoint superPickupPoint)
    {
        return toAjax(superPickupPointService.updateSuperPickupPoint(superPickupPoint));
    }

    /**
     * 删除自提点:自提点信息,字段包括id,名称,地址电话
     */
    @PreAuthorize("@ss.hasPermi('tool:pointpick:remove')")
    @Log(title = "自提点:自提点信息,字段包括id,名称,地址电话", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(superPickupPointService.deleteSuperPickupPointByIds(ids));
    }




    /**
     * 查询自提点:自提点信息,字段包括id,名称,地址电话列表
     */
    @PreAuthorize("@ss.hasPermi('tool:pointpick:list')")
    @GetMapping("/listAll")
    public TableDataInfo listAll()
    {
        List<SuperPickupPoint> list = superPickupPointService.selectSuperPickupPointList(null);
        return getDataTable(list);
    }
}
